/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package persistence;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author pabloavila
 */
@Entity
@Table(name = "PERMISOS")
@NamedQueries({
    @NamedQuery(name = "Permisos.findAll", query = "SELECT p FROM Permisos p"),
    @NamedQuery(name = "Permisos.findByPermPermiso", query = "SELECT p FROM Permisos p WHERE p.permPermiso = :permPermiso")})
public class Permisos implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "PERM_PERMISO")
    private String permPermiso;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "permisos")
    private Collection<Usuarios> usuariosCollection;

    public Permisos() {
    }

    public Permisos(String permPermiso) {
        this.permPermiso = permPermiso;
    }

    public String getPermPermiso() {
        return permPermiso;
    }

    public void setPermPermiso(String permPermiso) {
        this.permPermiso = permPermiso;
    }

    public Collection<Usuarios> getUsuariosCollection() {
        return usuariosCollection;
    }

    public void setUsuariosCollection(Collection<Usuarios> usuariosCollection) {
        this.usuariosCollection = usuariosCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (permPermiso != null ? permPermiso.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Permisos)) {
            return false;
        }
        Permisos other = (Permisos) object;
        if ((this.permPermiso == null && other.permPermiso != null) || (this.permPermiso != null && !this.permPermiso.equals(other.permPermiso))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "persistence.Permisos[permPermiso=" + permPermiso + "]";
    }

}
